package leetcode.code2100;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import leetcode.IDebug;
import leetcode.helper.HelpDebug;

public class Solution implements IDebug {

	public List<Integer> goodDaysToRobBank(int[] security, int time) {
		int len = security.length;
		int last = (int) 1e5 + 1, size = 0;
		Set<Integer> set = new HashSet<>();
		for (int i = 0; i < len - time; i++) {
			int cur = security[i];
			if (cur <= last) {
				size++;
			} else {
				size = 1;
			}
			if (size >= time + 1) {
				set.add(i);
			}
			last = cur;
		}
		List<Integer> ans = new ArrayList<>();
		last = (int) 1e5 + 1;
		size = 0;
		for (int i = len - 1; i >= time; i--) {
			int cur = security[i];
			if (cur <= last) {
				size++;
			} else {
				size = 1;
			}
			if (size >= time + 1 && set.contains(i)) {
				ans.add(i);
			}
			last = cur;
		}
		return ans;
	}

	@Override
	public void debug1() {
		List<Integer> ans = HelpDebug.str2intlist("[2,3]");
		HelpDebug.compare(ans, this.goodDaysToRobBank(HelpDebug.str2array3("[5,3,3,3,5,6,2]"), 2));

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();

	}

}
